import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

const actions = {
    showORhide: ({ commit, state }, opt) => {
        state.isShow = opt;
        commit("showORhide");
    },
    changeTitle: ({ commit, state }, opt) => {
        state.navTitle = opt;
        commit('changeTitle');
    }
};

const state = {
    isShow: parseInt(window.sessionStorage.getItem('isShow')),
    navTitle: window.sessionStorage.getItem('navTitle') ? window.sessionStorage.getItem('navTitle') : '我'
}
const mutations = {
    showORhide(state) {
        state.isShow = state.isShow;
    },
    changeTitle(state) {
        state.navTitle = state.navTitle;
    }
}

const getters = {
    isShow(state) {
        return state.isShow
    },
    navTitle(state) {
        return state.navTitle
    }
}

export default new Vuex.Store({
    state,
    actions,
    mutations,
    getters
})